package no.uib.kwikktaim.gui.actionlisteners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import no.uib.kwikktaim.gui.MainWindow;

public class ChangeTrack implements ActionListener{

	private MainWindow mw;

	public ChangeTrack(MainWindow caller) {
		mw = caller;
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getSource().equals(mw.getButtonPrevious()))
			mw.listPlayList.setSelectedIndex(Math.abs(mw.currentlyPlaying+1)%mw.model.getSize());
		else
			mw.listPlayList.setSelectedIndex(Math.abs((mw.model.getSize() + mw.currentlyPlaying-1)%mw.model.getSize()));
		mw.loadAndPlay();
	}

}
